/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DTO.DonHang_DTO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import DTO.ChiTietDonHang_DTO;
import java.sql.ResultSet;
/**
 *
 * @author xxx
 */
public class ChiTietDonHang_DAO {
    
    Database db = new Database();
    Connection conn = null;
    PreparedStatement pst = null;
    
    // Xem Chi tiet don hang
    
    public ArrayList<ChiTietDonHang_DTO> Xemchitietdonhang(int id) throws Exception
    {
        ArrayList<ChiTietDonHang_DTO> arr = new ArrayList<ChiTietDonHang_DTO>(); 
        String sql = "SELECT * FROM ChiTietDonhang where IDDonHang = " + id;       
        conn = db.open();
        pst = conn.prepareStatement(sql);
        
        ResultSet rs = pst.executeQuery();
        
        while (rs.next())
        {
            ChiTietDonHang_DTO ctdh = new ChiTietDonHang_DTO();   
            ctdh.setIDDonHang(rs.getInt("IDDonHang"));
            ctdh.setIDSanPham(rs.getInt("IDSanPham"));
            ctdh.setSoLuong(rs.getInt("SoLuong"));
            ctdh.setDonGia(rs.getInt("DonGia"));
            
           
            arr.add(ctdh);
        }
        db.close();
        return arr;
    }
    
}
